/*
 * spackage.c
 *
 *  Created on: 2013-5-20
 *      Author: xkaying
 */

#include "spackage.h"

#include "../common/list.h"

#include <assert.h>
#include <stdlib.h>

struct _spackagename
{
	List *name;
};

struct _spackage
{
	SPackageName *pname;
	//导入库
	List *pimport;
	List *penum;
	List *pinterface;
	List *pclass;
};

SPackageName *SPackageNameInit()
{
	SPackageName *pspn;
	pspn = (SPackageName*) malloc(sizeof(SPackageName));
	pspn->name = 0;
	return pspn;
}

void SPackageNamePush(SPackageName *package, char *name)
{
	assert(package);
	assert(name);
	if (package->name == 0) {
		package->name = ListInit();
	}
	ListPush(package->name, name);
}

SPackage *SPackageInit()
{
	SPackage *package;
	package = (SPackage*) malloc(sizeof(SPackage));
	package->pname = 0;
	package->pimport = 0;
	package->penum = 0;
	package->pclass = 0;
	package->pinterface = 0;
	return package;
}

void SPackagePush(SPackage *package, char *name)
{
	assert(package);
	assert(name);
	if (package->pname == 0) {
		package->pname = SPackageNameInit();
	}
	SPackageNamePush(package->pname, name);
}

void SPackagePushImport(SPackage *package, SPackageName *name)
{
	assert(package);
	assert(name);
	if (package->pimport == 0) {
		package->pimport = ListInit();
	}
	ListPush(package->pimport, name);
}

void SPackagePushEnum(SPackage *package,SEnum *penum)
{
	assert(package);
	assert(penum);
	if (package->penum== 0) {
		package->penum = ListInit();
	}
	ListPush(package->penum, penum);
}
